import java.util.Arrays;
import java.util.Scanner;

public class Test {

    //错误票据
    //在一行整数数据中，找出缺少的一个和重复的一个数

    //输入一个整数 n
    //输入 n 行整数数据

    private static final int N = 100000;
    private static int[] a = new int[N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = 0;
        while(scanner.hasNextInt()){
            a[cnt++] = scanner.nextInt();
        }
        //输入完成，进行排序
        Arrays.sort(a,0,cnt);

        int x = 0;
        int y = 0;
        for (int i = 0; i < cnt; i++) {
            if(a[i] + 2 == a[i + 1]){
                x = a[i] + 1;
            }else if (a[i + 1] == a[i]){
                y = a[i];
            }
        }
        System.out.println(x + " " + y);
    }

}
